import React, { useEffect, useState } from 'react'

export default function App3() {
    let [opacity, setOpacity] = useState(1)
    useEffect(() => {
        console.log('setOpacity执行了');
        const opacityTimer =setInterval(() => {
            opacity -= 0.1
            if (opacity<0) {
                opacity=1
            }
            setOpacity(opacity)
        },100)
        return ()=>{
            clearInterval(opacityTimer)
        }
    }, [])
    return (
        <div>
            <h1 style={{ opacity }}>React有点难，不想学了</h1>
        </div>
    )
}
